/*
 * B.cpp
 *
 *  Created on: Jun 14, 2013
 *      Author: SOFTFOUNDRY-VN
 */
#include <iostream>
#include <string>
using namespace std;

string s;
int val(char c) {
	return c - 'a';
}
int main() {
	cin >> s;
	long long count;
	int len = s.length();
	if (len < 5) {
		cout << 0 << "\n";
		return 0;
	}
	count = 0;
	int cm = 0;
	int num = ((((val(s[len-5]) * 26 + val(s[len-4])) * 26 + val(s[len-3])) * 26 + val(s[len-2])) * 26 + val(s[len-1]));
	int heavy = ((((val('h') * 26 + val('e')) * 26 + val('a')) * 26 + val('v')) * 26 + val('y'));
	int metal = ((((val('m') * 26 + val('e')) * 26 + val('t')) * 26 + val('a')) * 26 + val('l'));
	int idx = len-5;
	while (idx >= 0) {
		if (num == heavy) {
			count += cm;
		}
		else if (num == metal) {
			cm++;
		}
		idx--;
		if (idx >= 0) {
			num /= 26;
			num += val(s[idx])*26*26*26*26;
		}
	}

	cout << count << "\n";
	return 0;
}



